<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>职员修改</title>
		<link rel="stylesheet" href="../layui/css/layui.css" media="all">
		<style>
			.empAddBox{
				margin: 0 auto;
				margin-top: 80px;
				border: solid gainsboro 1px;
				width: 80%;
				padding: 20px;
				height: 60%;
				
			}
		</style>

	</head>
	<body>
		<div class="empAddBox">
			<form class="layui-form layui-form-pane" method="post" action="">
				<div class="layui-form-item">
					<label class="layui-form-label">项目</label>
					<div class="layui-input-inline">
						<input type="text" id="financeFeeDetail" name="employeeCode" lay-verify="required" placeholder="请输入项目名"
						 autocomplete="off" class="layui-input">
					</div>
					<label class="layui-form-label">财务费用</label>
					<div class="layui-input-inline">
						<input type="text" id="financeFee" name="employeeName" lay-verify="required" placeholder="请输入财务费用" autocomplete="off"
						 class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">支出日期</label>
						<div class="layui-input-inline">
							<input type="text" lay-verify="required" name="payoffDate" id="date1" placeholder="请选择支出日期" autocomplete="off"
							 class="layui-input">
						</div>
						<label class="layui-form-label">填写日期</label>
						<div class="layui-input-inline">
							<input type="text" lay-verify="required" name="payoffDate" id="date2" placeholder="请选择填写日期" autocomplete="off"
							 class="layui-input">
						</div>
					</div>
				</div>

				<div class="layui-form-item">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">确认添加</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</form>
		</div>
		<!-- <script type='text/javascript' src="js/jquery-3.4.1.min.js"></script> -->
		<script src="../layui/layui.js" charset="utf-8"></script>

		<script>
			layui.use(['form', 'laydate', 'jquery'], function() {

				var form = layui.form,
					layer = layui.layer,
					// layedit = layui.layedit,
					laydate = layui.laydate;
				var $ = layui.$;


				//日期
				laydate.render({
					elem: '#date1'
				});
				laydate.render({
					elem: '#date2',
				});
				//监听提交
				form.on('submit(demo1)', function(data) {
					var index = parent.layer.getFrameIndex(window.name);
					$.ajax({
						url: 'http://localhost:9000/cost/ffeeAdd',
						type: 'post',
						dataType: 'json',
						data: {
							"financeFeeDetail": $("#financeFeeDetail").val(),
							"financeFee": $("#financeFee").val(),
							"payoutMonth": $("#date1").val().toString(),
							"writeDate": $("#date2").val().toString(),
						},
						success: function(data1) {
							// 异常处理
							if (data1.code == 0) {
								layer.msg(JSON.stringify(data1.message), {

								});

								setTimeout(function() {
									parent.layer.close(index);
									parent.window.location.reload();
								}, 3000);
							} else {
								layer.msg(JSON.stringify(data1.message), {

								});

								// setTimeout(function() {
								// 	window.location.href = "empwarning.html";
								// }, 3000);

							}



						}
					})
					return false;
				});




				//表单取值
				layui.$('#LAY-component-form-getval').on('click', function() {
					var data = form.val('example');

					alert(JSON.stringify(data));
				});

			});
		</script>

	</body>

</html>
